const app = getApp();
import HttpRequst from '../../utils/httpRequst.js'
import API from '../../utils/config.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isAjax:false,
    capital:"",
    depositVal:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  onShow:function(){
    var that = this;
    HttpRequst(true, API.tiXian, 1, app.getUkey(), "", "POST", false, function (res) {
      
      if (res.code == 406) {
        wx.showModal({
          title: '提示',
          content: res.msg ? res.msg : "",
          cancelText: "我知道了",
          confirmText: "立刻绑定提现账号",
          success(res) {
            if (res.confirm) {
              wx.navigateTo({
                url: '/pages/setting/setting',
              })
            }
          }
        });
      } 
      that.setData({
        capital: res.data
      })
    })
  },
  getRemain:function(){
      this.setData({
        depositVal: this.data.capital.money
      })
  },
  getDepositVal:function(e){
    this.setData({
      depositVal:e.detail.value
    })
  },
  formSubmit:function(e){
    var that=this;
    this.setData({
      isAjax:true
    });
    HttpRequst(true, API.tiXianForm, 1, app.getUkey(), e.detail.value, "POST", false, function (res) {
      that.setData({
        isAjax: false
      });
      if(res.code!=400){
        setTimeout(function () {
          wx.showToast({
            title: '成功',
            icon: 'success',
            duration: 1000,
            success: function () {
              setTimeout(function () {
                wx.navigateTo({
                  url: '/pages/tiXianResult/tiXianResult?account=' + res.data.account+"&money="+res.data.money,
                })
              }, 1000)
            }
          })
        })
      }
      
    },true)
  }
})